<!DOCTYPE html>



  


<html class="theme-next gemini use-motion" lang="zh-Hans">
<head><meta name="generator" content="Hexo 3.9.0">
  <meta charset="UTF-8">
<meta http-equiv="X-UA-Compatible" content="IE=edge">
<meta name="viewport" content="width=device-width, initial-scale=1, maximum-scale=1">
<meta name="theme-color" content="#222">



  
  
    
      
    
    
      
    
  <script src="//cdn.bootcss.com/pace/1.0.2/pace.min.js"></script>
  <link href="//cdn.bootcss.com/pace/1.0.2/themes/blue/pace-theme-flash.min.css" rel="stylesheet">







<meta http-equiv="Cache-Control" content="no-transform">
<meta http-equiv="Cache-Control" content="no-siteapp">
















  
  
    
  
  <link href="//cdn.jsdelivr.net/fancybox/2.1.5/jquery.fancybox.min.css" rel="stylesheet" type="text/css">







  

<link href="//maxcdn.bootstrapcdn.com/font-awesome/4.7.0/css/font-awesome.min.css" rel="stylesheet" type="text/css">

<link href="/css/main.css?v=" rel="stylesheet" type="text/css">


  <link rel="apple-touch-icon" sizes="180x180" href="/images/apple-touch-icon-next.png?v=">


  <link rel="icon" type="image/png" sizes="32x32" href="/images/favicon.ico?v=">


  <link rel="icon" type="image/png" sizes="16x16" href="/images/favicon.ico?v=">


  <link rel="mask-icon" href="/images/logo.svg?v=" color="#222">





  <meta name="keywords" content="docker,">





  <link rel="alternate" href="/atom.xml" title="WhiteWater" type="application/atom+xml">






<meta name="description" content="docker命令使用 docker基本操作容器操作docker [run|start|stop|restart|kill|rm|pause|unpause]·  run /create[镜像名]：  创建一个新的容器并运行一个命令 ·  start/stop/restart[容器名]：启动/停止/重启一个容器 ·  kill [容器名]： 直接杀掉容器，不给进程响应时间 ·  rm[容器名]：删除">
<meta name="keywords" content="docker">
<meta property="og:type" content="article">
<meta property="og:title" content="docker入门(二) docker命令使用">
<meta property="og:url" content="http://yuanww.cn/2020/02/24/docker入门-二/index.html">
<meta property="og:site_name" content="WhiteWater">
<meta property="og:description" content="docker命令使用 docker基本操作容器操作docker [run|start|stop|restart|kill|rm|pause|unpause]·  run /create[镜像名]：  创建一个新的容器并运行一个命令 ·  start/stop/restart[容器名]：启动/停止/重启一个容器 ·  kill [容器名]： 直接杀掉容器，不给进程响应时间 ·  rm[容器名]：删除">
<meta property="og:locale" content="zh-Hans">
<meta property="og:image" content="http://yuanww.cn/2020/02/24/docker入门-二/docker.jpg">
<meta property="og:image" content="http://yuanww.cn/2020/02/24/docker入门-二/1.png">
<meta property="og:image" content="http://yuanww.cn/2020/02/24/docker入门-二/2.png">
<meta property="og:image" content="http://yuanww.cn/2020/02/24/docker入门-二/3.png">
<meta property="og:image" content="http://yuanww.cn/2020/02/24/docker入门-二/1582811371362.png">
<meta property="og:image" content="http://yuanww.cn/2020/02/24/docker入门-二/4.png">
<meta property="og:image" content="http://yuanww.cn/2020/02/24/docker入门-二/5.png">
<meta property="og:image" content="http://yuanww.cn/2020/02/24/docker入门-二/6.png">
<meta property="og:image" content="http://yuanww.cn/2020/02/24/docker入门-二/7.png">
<meta property="og:image" content="http://yuanww.cn/2020/02/24/docker入门-二/8.png">
<meta property="og:image" content="http://yuanww.cn/2020/02/24/docker入门-二/9.png">
<meta property="og:image" content="http://yuanww.cn/2020/02/24/docker入门-二/10.png">
<meta property="og:image" content="http://yuanww.cn/2020/02/24/docker入门-二/11.png">
<meta property="og:image" content="http://yuanww.cn/2020/02/24/docker入门-二/12.png">
<meta property="og:image" content="http://yuanww.cn/2020/02/24/docker入门-二/13.png">
<meta property="og:image" content="http://yuanww.cn/2020/02/24/docker入门-二/14.png">
<meta property="og:image" content="http://yuanww.cn/2020/02/24/docker入门-二/1582813889613.png">
<meta property="og:image" content="http://yuanww.cn/2020/02/24/docker入门-二/1582814035925.png">
<meta property="og:image" content="http://yuanww.cn/2020/02/24/docker入门-二/1582814207301.png">
<meta property="og:image" content="http://yuanww.cn/2020/02/24/docker入门-二/1582814266733.png">
<meta property="og:image" content="http://yuanww.cn/2020/02/24/docker入门-二/1582814323741.png">
<meta property="og:updated_time" content="2020-02-27T14:59:51.954Z">
<meta name="twitter:card" content="summary">
<meta name="twitter:title" content="docker入门(二) docker命令使用">
<meta name="twitter:description" content="docker命令使用 docker基本操作容器操作docker [run|start|stop|restart|kill|rm|pause|unpause]·  run /create[镜像名]：  创建一个新的容器并运行一个命令 ·  start/stop/restart[容器名]：启动/停止/重启一个容器 ·  kill [容器名]： 直接杀掉容器，不给进程响应时间 ·  rm[容器名]：删除">
<meta name="twitter:image" content="http://yuanww.cn/2020/02/24/docker入门-二/docker.jpg">



<script type="text/javascript" id="hexo.configurations">
  var NexT = window.NexT || {};
  var CONFIG = {
    root: '/',
    scheme: 'Gemini',
    version: '',
    sidebar: {"position":"left","display":"post","offset":12,"b2t":false,"scrollpercent":false,"onmobile":false},
    fancybox: true,
    tabs: true,
    motion: {"enable":true,"async":false,"transition":{"post_block":"fadeIn","post_header":"slideDownIn","post_body":"slideDownIn","coll_header":"slideLeftIn","sidebar":"slideUpIn"}},
    duoshuo: {
      userId: '0',
      author: '博主'
    },
    algolia: {
      applicationID: '',
      apiKey: '',
      indexName: '',
      hits: {"per_page":10},
      labels: {"input_placeholder":"Search for Posts","hits_empty":"We didn't find any results for the search: ${query}","hits_stats":"${hits} results found in ${time} ms"}
    }
  };
</script>



  <link rel="canonical" href="http://yuanww.cn/2020/02/24/docker入门-二/">





  <title>docker入门(二) docker命令使用 | WhiteWater</title>
  





  <script type="text/javascript">
    var _hmt = _hmt || [];
    (function() {
      var hm = document.createElement("script");
      hm.src = "https://hm.baidu.com/hm.js?e46442d1930481b98d53762512c55bc1";
      var s = document.getElementsByTagName("script")[0];
      s.parentNode.insertBefore(hm, s);
    })();
  </script>




</head>

<body itemscope itemtype="http://schema.org/WebPage" lang="zh-Hans">

  
  
    
  

  <div class="container sidebar-position-left page-post-detail">
    <div class="headband"></div>

    <header id="header" class="header" itemscope itemtype="http://schema.org/WPHeader">
      <div class="header-inner"><div class="site-brand-wrapper">
  <div class="site-meta ">
    

    <div class="custom-logo-site-title">
      <a href="/" class="brand" rel="start">
        <span class="logo-line-before"><i></i></span>
        <span class="site-title">WhiteWater</span>
        <span class="logo-line-after"><i></i></span>
      </a>
    </div>
      
        <p class="site-subtitle">Thirst most</p>
      
  </div>

  <div class="site-nav-toggle">
    <button>
      <span class="btn-bar"></span>
      <span class="btn-bar"></span>
      <span class="btn-bar"></span>
    </button>
  </div>
</div>

<nav class="site-nav">
  

  
    <ul id="menu" class="menu">
      
        
        <li class="menu-item menu-item-home">
          <a href="/" rel="section">
            
              <i class="menu-item-icon fa fa-fw fa-home"></i> <br>
            
            首页
          </a>
        </li>
      
        
        <li class="menu-item menu-item-about">
          <a href="/about/" rel="section">
            
              <i class="menu-item-icon fa fa-fw fa-user"></i> <br>
            
            关于
          </a>
        </li>
      
        
        <li class="menu-item menu-item-tags">
          <a href="/tags/" rel="section">
            
              <i class="menu-item-icon fa fa-fw fa-tags"></i> <br>
            
            标签
          </a>
        </li>
      
        
        <li class="menu-item menu-item-categories">
          <a href="/categories/" rel="section">
            
              <i class="menu-item-icon fa fa-fw fa-th"></i> <br>
            
            分类
          </a>
        </li>
      
        
        <li class="menu-item menu-item-archives">
          <a href="/archives/" rel="section">
            
              <i class="menu-item-icon fa fa-fw fa-archive"></i> <br>
            
            归档
          </a>
        </li>
      

      
    </ul>
  

  
</nav>



 </div>
    </header>

    <main id="main" class="main">
      <div class="main-inner">
        <div class="content-wrap">
          <div id="content" class="content">
            

  <div id="posts" class="posts-expand">
    

  

  
  
  

  <article class="post post-type-normal" itemscope itemtype="http://schema.org/Article">
  
  
  
  <div class="post-block">
    <link itemprop="mainEntityOfPage" href="http://yuanww.cn/2020/02/24/docker入门-二/">

    <span hidden itemprop="author" itemscope itemtype="http://schema.org/Person">
      <meta itemprop="name" content="ctrl">
      <meta itemprop="description" content>
      <meta itemprop="image" content="/images/bbb.gif">
    </span>

    <span hidden itemprop="publisher" itemscope itemtype="http://schema.org/Organization">
      <meta itemprop="name" content="WhiteWater">
    </span>

    
      <header class="post-header">

        
        
          <h1 class="post-title" itemprop="name headline">docker入门(二) docker命令使用</h1>
        

        <div class="post-meta">
          <span class="post-time">
            
              <span class="post-meta-item-icon">
                <i class="fa fa-calendar-o"></i>
              </span>
              
                <span class="post-meta-item-text">发表于</span>
              
              <time title="创建于" itemprop="dateCreated datePublished" datetime="2020-02-24T22:21:48+08:00">
                2020-02-24
              </time>
            

            

            
          </span>

          
            <span class="post-category">
            
              <span class="post-meta-divider">|</span>
            
              <span class="post-meta-item-icon">
                <i class="fa fa-folder-o"></i>
              </span>
              
                <span class="post-meta-item-text">分类于</span>
              
              
                <span itemprop="about" itemscope itemtype="http://schema.org/Thing">
                  <a href="/categories/docker/" itemprop="url" rel="index">
                    <span itemprop="name">docker</span>
                  </a>
                </span>

                
                
              
            </span>
          

          
            
              <span class="post-comments-count">
                <span class="post-meta-divider">|</span>
                <span class="post-meta-item-icon">
                  <i class="fa fa-comment-o"></i>
                </span>
                <a href="/2020/02/24/docker入门-二/#comments" itemprop="discussionUrl">
                  <span class="post-comments-count valine-comment-count" data-xid="/2020/02/24/docker入门-二/" itemprop="commentCount"></span>
                </a>
              </span>
            
          

          
          
             <span id="/2020/02/24/docker入门-二/" class="leancloud_visitors" data-flag-title="docker入门(二) docker命令使用">
               <span class="post-meta-divider">|</span>
               <span class="post-meta-item-icon">
                 <i class="fa fa-eye"></i>
               </span>
               
                 <span class="post-meta-item-text">阅读次数&#58;</span>
               
                 <span class="leancloud-visitors-count"></span>
             </span>
          

          
            <div class="post-wordcount">
              
                
                <span class="post-meta-item-icon">
                  <i class="fa fa-file-word-o"></i>
                </span>
                
                  <span class="post-meta-item-text">字数统计&#58;</span>
                
                <span title="字数统计">
                  1.6k
                </span>
              

              
                <span class="post-meta-divider">|</span>
              

              
                <span class="post-meta-item-icon">
                  <i class="fa fa-clock-o"></i>
                </span>
                
                  <span class="post-meta-item-text">阅读时长 &asymp;</span>
                
                <span title="阅读时长">
                  6
                </span>
              
            </div>
          

          

        </div>
      </header>
    

    
    
    
    <div class="post-body" itemprop="articleBody">

      
      

      
        <h1 id="docker命令使用"><a href="#docker命令使用" class="headerlink" title="docker命令使用"></a>docker命令使用</h1><p><img src="/2020/02/24/docker入门-二/docker.jpg" alt></p>
<h2 id="docker基本操作"><a href="#docker基本操作" class="headerlink" title="docker基本操作"></a>docker基本操作</h2><h3 id="容器操作"><a href="#容器操作" class="headerlink" title="容器操作"></a>容器操作</h3><h3 id="docker-run-start-stop-restart-kill-rm-pause-unpause"><a href="#docker-run-start-stop-restart-kill-rm-pause-unpause" class="headerlink" title="docker [run|start|stop|restart|kill|rm|pause|unpause]"></a>docker [run|start|stop|restart|kill|rm|pause|unpause]</h3><p>·  <a href="http://www.runoob.com/docker/docker-run-command.html" target="_blank" rel="noopener">run</a> /<a href="http://www.runoob.com/docker/docker-create-command.html" target="_blank" rel="noopener">create</a>[镜像名]：  创建一个新的容器并运行一个命令</p>
<p>·  <a href="http://www.runoob.com/docker/docker-start-stop-restart-command.html" target="_blank" rel="noopener">start/stop/restart</a>[容器名]：启动/停止/重启一个容器</p>
<p>·  <a href="http://www.runoob.com/docker/docker-kill-command.html" target="_blank" rel="noopener">kill</a> [容器名]： 直接杀掉容器，不给进程响应时间</p>
<p>·  <a href="http://www.runoob.com/docker/docker-rm-command.html" target="_blank" rel="noopener">rm</a>[容器名]：删除已经停止的容器</p>
<p>·  <a href="http://www.runoob.com/docker/docker-pause-unpause-command.html" target="_blank" rel="noopener">pause/unpause</a>[容器名]：暂停/恢复容器中的进程</p>
<a id="more"></a>
<h3 id="docker-ps-inspect-exec-logs-export-import"><a href="#docker-ps-inspect-exec-logs-export-import" class="headerlink" title="docker [ps|inspect|exec|logs|export|import]"></a>docker [ps|inspect|exec|logs|export|import]</h3><p>·  <a href="http://www.runoob.com/docker/docker-ps-command.html" target="_blank" rel="noopener">ps</a>：查看容器列表（默认查看正在运行的容器，-a查看所有容器）</p>
<p>·  <a href="http://www.runoob.com/docker/docker-inspect-command.html" target="_blank" rel="noopener">inspect</a>[容器名]：查看容器配置元数据</p>
<p>·  <a href="https://www.runoob.com/docker/docker-exec-command.html" target="_blank" rel="noopener">exec -it </a>[容器名] /bin/bash：进入容器环境中交互操作</p>
<p>·  <a href="https://www.runoob.com/docker/docker-logs-command.html" target="_blank" rel="noopener">logs</a> [容器名]:查看容器日志 </p>
<p>·  <a href="https://www.runoob.com/docker/docker-cp-command.html" target="_blank" rel="noopener">cp</a> path1 [容器名]:path  容器与主机之间的数据拷贝</p>
<p>·  <a href="https://www.runoob.com/docker/docker-export-command.html" target="_blank" rel="noopener">export</a> -o test.tar  [容器名] : 文件系统作为一个tar归档文件</p>
<p>·  <a href="https://www.runoob.com/docker/docker-import-command.html" target="_blank" rel="noopener">import</a> test.tar [镜像名版本号]:导入归档文件，成为一个镜像</p>
<h3 id="镜像操作"><a href="#镜像操作" class="headerlink" title="镜像操作"></a>镜像操作</h3><h3 id="docker-images-rmi-tag-build-history-save-load"><a href="#docker-images-rmi-tag-build-history-save-load" class="headerlink" title="docker images|rmi|tag|build|history|save|load]"></a>docker images|rmi|tag|build|history|save|load]</h3><p>·  <a href="http://www.runoob.com/docker/docker-images-command.html" target="_blank" rel="noopener">images</a>：列出本地镜像列表</p>
<p>·  <a href="http://www.runoob.com/docker/docker-rmi-command.html" target="_blank" rel="noopener">rmi</a> [镜像名：版本]：删除镜像</p>
<p>·  <a href="https://www.runoob.com/docker/docker-tag-command.html" target="_blank" rel="noopener">tag</a> [镜像名：版本] [仓库]/[镜像名：版本]：标记本地镜像，将其归入某一仓库</p>
<p>·  <a href="http://www.runoob.com/docker/docker-build-command.html" target="_blank" rel="noopener">build</a> -t [镜像名：版本] [path]：Dockerfile 创建镜像</p>
<p>·  <a href="http://www.runoob.com/docker/docker-history-command.html" target="_blank" rel="noopener">history</a> [镜像名：版本]: 查看指定镜像的创建历史</p>
<p>·  <a href="https://www.runoob.com/docker/docker-save-command.html" target="_blank" rel="noopener">save</a> -o xxx.tar [镜像名：版本]: 将镜像保存成 tar归档文件</p>
<p>·  <a href="https://www.runoob.com/docker/docker-load-command.html" target="_blank" rel="noopener">load</a> –input  xx.tar  : 从归档文件加载镜像</p>
<h2 id="docker常用命令"><a href="#docker常用命令" class="headerlink" title="docker常用命令"></a>docker常用命令</h2><h3 id="交互式创建容器并进入"><a href="#交互式创建容器并进入" class="headerlink" title="交互式创建容器并进入"></a>交互式创建容器并进入</h3><p><img src="/2020/02/24/docker入门-二/1.png" alt></p>
<p><code>docker run -it --name centos centos /bin/bash</code>（前台进程） </p>
<p><code>exit</code>退出也关闭容器; <code>Ctrl+P+Q</code>退出不关闭容器 </p>
<p><img src="/2020/02/24/docker入门-二/2.png" alt></p>
<h3 id="后台启动容器"><a href="#后台启动容器" class="headerlink" title="后台启动容器"></a>后台启动容器</h3><p><img src="/2020/02/24/docker入门-二/3.png" alt></p>
<p><code>docker run -d --name nginx nginx</code></p>
<h3 id="进入已运行的容器"><a href="#进入已运行的容器" class="headerlink" title="进入已运行的容器"></a>进入已运行的容器</h3><p><code>docker exec -it nginx /bin/bash</code></p>
<h3 id="绑定容器端口到主机启动容器"><a href="#绑定容器端口到主机启动容器" class="headerlink" title="绑定容器端口到主机启动容器"></a>绑定容器端口到主机启动容器</h3><p><code>docker run -d -p 8080:80 --name nginx nginx:latest</code></p>
<h2 id="docker仓库使用"><a href="#docker仓库使用" class="headerlink" title="docker仓库使用"></a>docker仓库使用</h2><p>仓库（Repository）是集中存放镜像的地方。以下介绍一下 <a href="https://hub.docker.com/" target="_blank" rel="noopener">Docker Hub</a>。当然不止 docker hub，只是远程的服务商不一样，操作都是一样的。</p>
<h3 id="Docker-Hub"><a href="#Docker-Hub" class="headerlink" title="Docker Hub"></a>Docker Hub</h3><p>目前 Docker 官方维护了一个公共仓库 <a href="https://hub.docker.com/" target="_blank" rel="noopener">Docker Hub</a>。</p>
<p>大部分需求都可以通过在 Docker Hub 中直接下载镜像来实现。</p>
<h3 id="注册"><a href="#注册" class="headerlink" title="注册"></a>注册</h3><p>在 <a href="https://hub.docker.com/" target="_blank" rel="noopener">https://hub.docker.com</a> 免费注册一个 Docker 账号。</p>
<p>登录需要输入用户名和密码，登录成功后，我们就可以从 docker hub 上拉取自己账号下的全部镜像。</p>
<figure class="highlight java"><table><tr><td class="gutter"><pre><span class="line">1</span><br><span class="line">2</span><br><span class="line">3</span><br><span class="line">4</span><br></pre></td><td class="code"><pre><span class="line"># 登录</span><br><span class="line">docker login</span><br><span class="line"># 退出</span><br><span class="line">docker logout</span><br></pre></td></tr></table></figure>
<h3 id="拉取镜像"><a href="#拉取镜像" class="headerlink" title="拉取镜像"></a>拉取镜像</h3><p>你可以通过 docker search 命令来查找官方仓库中的镜像，并利用 docker pull 命令来将它下载到本地。</p>
<p>以 centos为关键词进行搜索：</p>
<p><img src="/2020/02/24/docker入门-二/1582811371362.png" alt="1582811371362"></p>
<figure class="highlight java"><table><tr><td class="gutter"><pre><span class="line">1</span><br><span class="line">2</span><br><span class="line">3</span><br><span class="line">4</span><br></pre></td><td class="code"><pre><span class="line"># 默认下载last版本 最新版本</span><br><span class="line">docker pull centos</span><br><span class="line"># 下载指定版本 centos7版本</span><br><span class="line">docker pull centos:centos7</span><br></pre></td></tr></table></figure>
<h2 id="docker-数据管理"><a href="#docker-数据管理" class="headerlink" title="docker 数据管理"></a>docker 数据管理</h2><p>docker容器运行，产生一些数据/文件/等等持久化的东西，不应该放在容器内部。应当以挂载的形式存在主机文件系统中。</p>
<h3 id="docker的文件系统"><a href="#docker的文件系统" class="headerlink" title="docker的文件系统"></a>docker的文件系统</h3><p><img src="/2020/02/24/docker入门-二/4.png" alt></p>
<ol>
<li><p>镜像与容器读写层，通过联合文件系统，组成系统文件视角</p>
</li>
<li><p>容器服务运行中，一定会生成数据</p>
</li>
<li><p>容器只是运行态的服务器，是瞬时的，不承载数据的持久功能</p>
</li>
</ol>
<h3 id="volume文件挂载的探究"><a href="#volume文件挂载的探究" class="headerlink" title="volume文件挂载的探究"></a>volume文件挂载的探究</h3><p>1、volume参数创建容器数据卷</p>
<p><img src="/2020/02/24/docker入门-二/5.png" alt></p>
<p>2、我们通过docker inspect data查看容器元数据，可看到挂载信息</p>
<p><img src="/2020/02/24/docker入门-二/6.png" alt></p>
<p><img src="/2020/02/24/docker入门-二/7.png" alt></p>
<p>3、在容器端添加一个文件</p>
<p><img src="/2020/02/24/docker入门-二/8.png" alt></p>
<p>回主机目录查看，果然存在此文件：</p>
<p><img src="/2020/02/24/docker入门-二/9.png" alt></p>
<p>4、在主机方添加一个文件</p>
<p><img src="/2020/02/24/docker入门-二/10.png" alt></p>
<p>回容器里查看，果然也同步增加了此文件</p>
<p><img src="/2020/02/24/docker入门-二/11.png" alt></p>
<p>5、指定主机目录方式挂载文件</p>
<p>格式：-v path1：path2</p>
<p>如下命令，容器方会自动增加一个data目录</p>
<p><img src="/2020/02/24/docker入门-二/12.png" alt></p>
<p>宿主机方，同样自动增加一个/opt/data目录</p>
<p><img src="/2020/02/24/docker入门-二/13.png" alt></p>
<h2 id="Dockerfile使用"><a href="#Dockerfile使用" class="headerlink" title="Dockerfile使用"></a>Dockerfile使用</h2><h3 id="什么是-Dockerfile？"><a href="#什么是-Dockerfile？" class="headerlink" title="什么是 Dockerfile？"></a>什么是 Dockerfile？</h3><p>Dockerfile 是一个用来构建镜像的文本文件，文本内容包含了一条条的指令<strong>，</strong>每一条指令构建一层，因此每一条指令的内容，就是描述该层应当如何构建。</p>
<h3 id="dockerfile基本要素"><a href="#dockerfile基本要素" class="headerlink" title="dockerfile基本要素"></a>dockerfile基本要素</h3><p><img src="/2020/02/24/docker入门-二/14.png" alt></p>
<table>
<thead>
<tr>
<th>指令</th>
<th>含义</th>
</tr>
</thead>
<tbody>
<tr>
<td>FROM镜像</td>
<td>指定新镜像所基于的镜像，必须为第一条指令</td>
</tr>
<tr>
<td>MAINTAINER 名字</td>
<td>新镜像的维护人信息</td>
</tr>
<tr>
<td>RUN 命令</td>
<td>在所基于的镜像上执行命令，并提交到新镜像中</td>
</tr>
<tr>
<td>EXPOSE端口号</td>
<td>指定新镜像加载到Docker时开启的端口号</td>
</tr>
<tr>
<td>ENV 环境变量 变量值</td>
<td>设置一个环境变量的值，会被后面的RUN使用</td>
</tr>
<tr>
<td>ADD 源文件/目录 目标文件/目录</td>
<td>将源文件复制到目标文件，源文件要与Docker位于同一目录下，或者为一个URL</td>
</tr>
<tr>
<td>COPY 源文件/目录 目标文件/目录</td>
<td>将本地主机上的源文件/目录复制到目标地点，源文件/目录要与Dockerfile在同一目录下</td>
</tr>
<tr>
<td>VOLUME[“目录”]</td>
<td>在容器中创建一个挂载点</td>
</tr>
<tr>
<td>USER 用户名 /UID</td>
<td>指定运行容器时的用户</td>
</tr>
<tr>
<td>WORKDIR 路径</td>
<td>为后续的RUN、CMD、ENTRYPOINT指定工作目录</td>
</tr>
<tr>
<td>ONBUILD命令</td>
<td>指定所生成的镜像作为一个基础镜像时所要运行的命令</td>
</tr>
<tr>
<td>CMD[“要运行的程序”，”参数1”，”参数2”]</td>
<td>指定启动容器时运行的命令或脚本，只能有一条CMD命令，多条时只有最后一条被执行</td>
</tr>
</tbody>
</table>
<h3 id="使用-Dockerfile-创建httpd镜像"><a href="#使用-Dockerfile-创建httpd镜像" class="headerlink" title="使用 Dockerfile 创建httpd镜像"></a>使用 Dockerfile 创建httpd镜像</h3><h4 id="1-创建镜像工作目录并进入"><a href="#1-创建镜像工作目录并进入" class="headerlink" title="1.创建镜像工作目录并进入"></a>1.创建镜像工作目录并进入</h4><figure class="highlight java"><table><tr><td class="gutter"><pre><span class="line">1</span><br><span class="line">2</span><br><span class="line">3</span><br></pre></td><td class="code"><pre><span class="line">mkdir apache</span><br><span class="line"></span><br><span class="line">cd apache/</span><br></pre></td></tr></table></figure>
<h4 id="2-创建并编写dockerfile文件"><a href="#2-创建并编写dockerfile文件" class="headerlink" title="2.创建并编写dockerfile文件"></a>2.创建并编写dockerfile文件</h4><figure class="highlight java"><table><tr><td class="gutter"><pre><span class="line">1</span><br><span class="line">2</span><br><span class="line">3</span><br><span class="line">4</span><br><span class="line">5</span><br><span class="line">6</span><br><span class="line">7</span><br><span class="line">8</span><br><span class="line">9</span><br><span class="line">10</span><br><span class="line">11</span><br><span class="line">12</span><br><span class="line">13</span><br><span class="line">14</span><br><span class="line">15</span><br><span class="line">16</span><br><span class="line">17</span><br><span class="line">18</span><br><span class="line">19</span><br><span class="line">20</span><br><span class="line">21</span><br><span class="line">22</span><br><span class="line">23</span><br><span class="line">24</span><br><span class="line">25</span><br><span class="line">26</span><br></pre></td><td class="code"><pre><span class="line">vim Dockerfile</span><br><span class="line"></span><br><span class="line">*******文件内容******************* </span><br><span class="line"></span><br><span class="line">#基于centos镜像</span><br><span class="line">FROM centos</span><br><span class="line"></span><br><span class="line">#维护人的信息</span><br><span class="line">MAINTAINER The CentOS Project &lt;<span class="number">123456789</span><span class="meta">@qq</span>.com&gt;</span><br><span class="line"></span><br><span class="line">#安装httpd软件包</span><br><span class="line">RUN yum -y update</span><br><span class="line">RUN yum -y install httpd</span><br><span class="line"></span><br><span class="line">#开启80端口</span><br><span class="line">EXPOSE <span class="number">80</span></span><br><span class="line"></span><br><span class="line">#复制网站首页文件至镜像中web站点下</span><br><span class="line">ADD index.html /var/www/html/index.html</span><br><span class="line"></span><br><span class="line">#复制该脚本至镜像中，并修改其权限</span><br><span class="line">ADD run.sh /run.sh</span><br><span class="line">RUN chmod <span class="number">775</span> /run.sh</span><br><span class="line"></span><br><span class="line">#当启动容器时执行的脚本文件</span><br><span class="line">CMD [<span class="string">"/run.sh"</span>]</span><br></pre></td></tr></table></figure>
<p><img src="/2020/02/24/docker入门-二/1582813889613.png" alt="1582813889613"></p>
<h4 id="3-创建脚本文件"><a href="#3-创建脚本文件" class="headerlink" title="3.创建脚本文件"></a>3.创建脚本文件</h4><figure class="highlight java"><table><tr><td class="gutter"><pre><span class="line">1</span><br><span class="line">2</span><br><span class="line">3</span><br><span class="line">4</span><br><span class="line">5</span><br><span class="line">6</span><br><span class="line">7</span><br><span class="line">8</span><br><span class="line">9</span><br><span class="line">10</span><br><span class="line">11</span><br></pre></td><td class="code"><pre><span class="line">vim run.sh</span><br><span class="line"></span><br><span class="line">*****文件内容*******</span><br><span class="line"></span><br><span class="line">#!/bin/bash</span><br><span class="line"></span><br><span class="line">#清空httpd缓存文件</span><br><span class="line">rm -rf /run/httpd<span class="comment">/*</span></span><br><span class="line"><span class="comment"></span></span><br><span class="line"><span class="comment">#启动httpd服务</span></span><br><span class="line"><span class="comment">exec /usr/sbin/apachectl -D FOREGROUND</span></span><br></pre></td></tr></table></figure>
<h4 id="4-创建网站首页文件"><a href="#4-创建网站首页文件" class="headerlink" title="4.创建网站首页文件"></a>4.创建网站首页文件</h4><figure class="highlight java"><table><tr><td class="gutter"><pre><span class="line">1</span><br></pre></td><td class="code"><pre><span class="line">echo <span class="string">"Thiss is Nginx webapp."</span> &gt; index.html</span><br></pre></td></tr></table></figure>
<h4 id="5-查看当前目录文件列表"><a href="#5-查看当前目录文件列表" class="headerlink" title="5.查看当前目录文件列表"></a>5.查看当前目录文件列表</h4><p><img src="/2020/02/24/docker入门-二/1582814035925.png" alt="1582814035925"></p>
<h4 id="6-通过Dockerfile文件生成镜像"><a href="#6-通过Dockerfile文件生成镜像" class="headerlink" title="6.通过Dockerfile文件生成镜像"></a>6.通过Dockerfile文件生成镜像</h4><figure class="highlight java"><table><tr><td class="gutter"><pre><span class="line">1</span><br></pre></td><td class="code"><pre><span class="line">docker build -t httpd:centos</span><br></pre></td></tr></table></figure>
<p><img src="/2020/02/24/docker入门-二/1582814207301.png" alt="1582814207301"></p>
<h4 id="7-镜像文件加载到容器中运行"><a href="#7-镜像文件加载到容器中运行" class="headerlink" title="7.镜像文件加载到容器中运行"></a>7.镜像文件加载到容器中运行</h4><figure class="highlight java"><table><tr><td class="gutter"><pre><span class="line">1</span><br></pre></td><td class="code"><pre><span class="line">docker run -d -p <span class="number">80</span>:<span class="number">80</span> --name=httpd httpd:centos</span><br></pre></td></tr></table></figure>
<h4 id="8-查看运行中的容器"><a href="#8-查看运行中的容器" class="headerlink" title="8.查看运行中的容器"></a>8.查看运行中的容器</h4><p><img src="/2020/02/24/docker入门-二/1582814266733.png" alt="1582814266733"></p>
<h4 id="9-运行浏览器测试httpd服务"><a href="#9-运行浏览器测试httpd服务" class="headerlink" title="9.运行浏览器测试httpd服务"></a>9.运行浏览器测试httpd服务</h4><p><img src="/2020/02/24/docker入门-二/1582814323741.png" alt="1582814323741"></p>
<h2 id="参考文章"><a href="#参考文章" class="headerlink" title="参考文章"></a>参考文章</h2><p><a href="https://www.runoob.com/docker/docker-image-usage.html" target="_blank" rel="noopener">https://www.runoob.com/docker/docker-image-usage.html</a></p>
<p><a href="https://blog.51cto.com/10316297/2160524" target="_blank" rel="noopener">https://blog.51cto.com/10316297/2160524</a></p>

      
    </div>
    
    
    
    <div>
      
        
<div class="my_post_copyright">
  <script src="//cdn.bootcss.com/clipboard.js/1.5.10/clipboard.min.js"></script>

  <!-- JS库 sweetalert 可修改路径 -->
  <script src="https://cdn.bootcss.com/jquery/2.0.0/jquery.min.js"></script>
  <script src="https://unpkg.com/sweetalert/dist/sweetalert.min.js"></script>
  <p><span>本文标题:</span><a href="/2020/02/24/docker入门-二/">docker入门(二) docker命令使用</a></p>
  <p><span>文章作者:</span><a href="/" title="访问 ctrl 的个人博客">ctrl</a></p>
  <p><span>发布时间:</span>2020年02月24日 - 22:02</p>
  <p><span>最后更新:</span>2020年02月27日 - 22:02</p>
  <p><span>原始链接:</span><a href="/2020/02/24/docker入门-二/" title="docker入门(二) docker命令使用">http://yuanww.cn/2020/02/24/docker入门-二/</a>
    <span class="copy-path" title="点击复制文章链接"><i class="fa fa-clipboard" data-clipboard-text="http://yuanww.cn/2020/02/24/docker入门-二/" aria-label="复制成功！"></i></span>
  </p>
  <p><span>许可协议:</span><i class="fa fa-creative-commons"></i> <a rel="license" href="https://creativecommons.org/licenses/by-nc-nd/4.0/" target="_blank" title="Attribution-NonCommercial-NoDerivatives 4.0 International (CC BY-NC-ND 4.0)">署名-非商业性使用-禁止演绎 4.0 国际</a> 转载请保留原文链接及作者。</p>
</div>
<script>
    var clipboard = new Clipboard('.fa-clipboard');
    $(".fa-clipboard").click(function(){
      clipboard.on('success', function(){
        swal({
          title: "",
          text: '复制成功',
          icon: "success",
          showConfirmButton: true
          });
    });
    });
</script>


      
    </div>

    

    <div>
      
        <div>
    
        <br>
        <div style="text-align:center;color: #ccc;font-size:30px;">-------------本文结束<i class="fa fa-paw"></i>感谢您的阅读-------------</div>
    
</div>

      
    </div>

    

    

    <footer class="post-footer">
      
        <div class="post-tags">
          
            <a href="/tags/docker/" rel="tag"><i class="fa fa-tag"></i> docker</a>
          
        </div>
      

      
      
      

      
        <div class="post-nav">
          <div class="post-nav-next post-nav-item">
            
              <a href="/2020/02/20/docker入门-一/" rel="next" title="docker入门(一) Dokcer介绍和安装">
                <i class="fa fa-chevron-left"></i> docker入门(一) Dokcer介绍和安装
              </a>
            
          </div>

          <span class="post-nav-divider"></span>

          <div class="post-nav-prev post-nav-item">
            
              <a href="/2020/02/27/docker入门-三/" rel="prev" title="docker入门(三) docker整合springboot项目">
                docker入门(三) docker整合springboot项目 <i class="fa fa-chevron-right"></i>
              </a>
            
          </div>
        </div>
      

      
      
    </footer>
  </div>
  
  
  
  </article>



    <div class="post-spread">
      
        
  <div class="bdsharebuttonbox">
    <a href="#" class="bds_tsina" data-cmd="tsina" title="分享到新浪微博"></a>
    <a href="#" class="bds_douban" data-cmd="douban" title="分享到豆瓣网"></a>
    <a href="#" class="bds_sqq" data-cmd="sqq" title="分享到QQ好友"></a>
    <a href="#" class="bds_qzone" data-cmd="qzone" title="分享到QQ空间"></a>
    <a href="#" class="bds_weixin" data-cmd="weixin" title="分享到微信"></a>
    <a href="#" class="bds_tieba" data-cmd="tieba" title="分享到百度贴吧"></a>
    <a href="#" class="bds_twi" data-cmd="twi" title="分享到Twitter"></a>
    <a href="#" class="bds_fbook" data-cmd="fbook" title="分享到Facebook"></a>
    <a href="#" class="bds_more" data-cmd="more"></a>
    <a class="bds_count" data-cmd="count"></a>
  </div>
  <script>
    window._bd_share_config = {
      "common": {
        "bdText": "",
        "bdMini": "2",
        "bdMiniList": false,
        "bdPic": ""
      },
      "share": {
        "bdSize": "16",
        "bdStyle": "0"
      },
      "image": {
        "viewList": ["tsina", "douban", "sqq", "qzone", "weixin", "twi", "fbook"],
        "viewText": "分享到：",
        "viewSize": "16"
      }
    }
  </script>

<script>
  with(document)0[(getElementsByTagName('head')[0]||body).appendChild(createElement('script')).src='/static/api/js/share.js?v=89860593.js?cdnversion='+~(-new Date()/36e5)];
</script>

      
    </div>
  </div>


          </div>
          


          

  
    <div class="comments" id="comments">
    </div>
  



        </div>
        
          
  
  <div class="sidebar-toggle">
    <div class="sidebar-toggle-line-wrap">
      <span class="sidebar-toggle-line sidebar-toggle-line-first"></span>
      <span class="sidebar-toggle-line sidebar-toggle-line-middle"></span>
      <span class="sidebar-toggle-line sidebar-toggle-line-last"></span>
    </div>
  </div>

  <aside id="sidebar" class="sidebar">
    
    <div class="sidebar-inner">

      

      
        <ul class="sidebar-nav motion-element">
          <li class="sidebar-nav-toc sidebar-nav-active" data-target="post-toc-wrap">
            文章目录
          </li>
          <li class="sidebar-nav-overview" data-target="site-overview-wrap">
            站点概览
          </li>
        </ul>
      

      <section class="site-overview-wrap sidebar-panel">
        <div class="site-overview">
          <div class="site-author motion-element" itemprop="author" itemscope itemtype="http://schema.org/Person">
            
              <img class="site-author-image" itemprop="image" src="/images/bbb.gif" alt="ctrl">
            
              <p class="site-author-name" itemprop="name">ctrl</p>
              <p class="site-description motion-element" itemprop="description">毕业时长两年半的CV工程师</p>
          </div>

          <nav class="site-state motion-element">

            
              <div class="site-state-item site-state-posts">
              
                <a href="/archives/">
              
                  <span class="site-state-item-count">20</span>
                  <span class="site-state-item-name">日志</span>
                </a>
              </div>
            

            
              
              
              <div class="site-state-item site-state-categories">
                <a href="/categories/index.html">
                  <span class="site-state-item-count">7</span>
                  <span class="site-state-item-name">分类</span>
                </a>
              </div>
            

            
              
              
              <div class="site-state-item site-state-tags">
                <a href="/tags/index.html">
                  <span class="site-state-item-count">13</span>
                  <span class="site-state-item-name">标签</span>
                </a>
              </div>
            

          </nav>

          
            <div class="feed-link motion-element">
              <a href="/atom.xml" rel="alternate">
                <i class="fa fa-rss"></i>
                RSS
              </a>
            </div>
          

          
            <div class="links-of-author motion-element">
                
                  <span class="links-of-author-item">
                    <a href="https://github.com/yuan2658" target="_blank" title="GitHub">
                      
                        <i class="fa fa-fw fa-github"></i>GitHub</a>
                  </span>
                
            </div>
          

          
          

          
          
            <div class="links-of-blogroll motion-element links-of-blogroll-block">
              <div class="links-of-blogroll-title">
                <i class="fa  fa-fw fa-link"></i>
                Links
              </div>
              <ul class="links-of-blogroll-list">
                
                  <li class="links-of-blogroll-item">
                    <a href="https://juejin.im" title="掘金" target="_blank">掘金</a>
                  </li>
                
                  <li class="links-of-blogroll-item">
                    <a href="https://www.zhihu.com" title="知乎" target="_blank">知乎</a>
                  </li>
                
                  <li class="links-of-blogroll-item">
                    <a href="http://www.spring4all.com" title="Spring For All" target="_blank">Spring For All</a>
                  </li>
                
                  <li class="links-of-blogroll-item">
                    <a href="https://www.v2ex.com" title="印记中文" target="_blank">印记中文</a>
                  </li>
                
              </ul>
            </div>
          

          

        </div>
      </section>

      
      <!--noindex-->
        <section class="post-toc-wrap motion-element sidebar-panel sidebar-panel-active">
          <div class="post-toc">

            
              
            

            
              <div class="post-toc-content"><ol class="nav"><li class="nav-item nav-level-1"><a class="nav-link" href="#docker命令使用"><span class="nav-number">1.</span> <span class="nav-text">docker命令使用</span></a><ol class="nav-child"><li class="nav-item nav-level-2"><a class="nav-link" href="#docker基本操作"><span class="nav-number">1.1.</span> <span class="nav-text">docker基本操作</span></a><ol class="nav-child"><li class="nav-item nav-level-3"><a class="nav-link" href="#容器操作"><span class="nav-number">1.1.1.</span> <span class="nav-text">容器操作</span></a></li><li class="nav-item nav-level-3"><a class="nav-link" href="#docker-run-start-stop-restart-kill-rm-pause-unpause"><span class="nav-number">1.1.2.</span> <span class="nav-text">docker [run|start|stop|restart|kill|rm|pause|unpause]</span></a></li><li class="nav-item nav-level-3"><a class="nav-link" href="#docker-ps-inspect-exec-logs-export-import"><span class="nav-number">1.1.3.</span> <span class="nav-text">docker [ps|inspect|exec|logs|export|import]</span></a></li><li class="nav-item nav-level-3"><a class="nav-link" href="#镜像操作"><span class="nav-number">1.1.4.</span> <span class="nav-text">镜像操作</span></a></li><li class="nav-item nav-level-3"><a class="nav-link" href="#docker-images-rmi-tag-build-history-save-load"><span class="nav-number">1.1.5.</span> <span class="nav-text">docker images|rmi|tag|build|history|save|load]</span></a></li></ol></li><li class="nav-item nav-level-2"><a class="nav-link" href="#docker常用命令"><span class="nav-number">1.2.</span> <span class="nav-text">docker常用命令</span></a><ol class="nav-child"><li class="nav-item nav-level-3"><a class="nav-link" href="#交互式创建容器并进入"><span class="nav-number">1.2.1.</span> <span class="nav-text">交互式创建容器并进入</span></a></li><li class="nav-item nav-level-3"><a class="nav-link" href="#后台启动容器"><span class="nav-number">1.2.2.</span> <span class="nav-text">后台启动容器</span></a></li><li class="nav-item nav-level-3"><a class="nav-link" href="#进入已运行的容器"><span class="nav-number">1.2.3.</span> <span class="nav-text">进入已运行的容器</span></a></li><li class="nav-item nav-level-3"><a class="nav-link" href="#绑定容器端口到主机启动容器"><span class="nav-number">1.2.4.</span> <span class="nav-text">绑定容器端口到主机启动容器</span></a></li></ol></li><li class="nav-item nav-level-2"><a class="nav-link" href="#docker仓库使用"><span class="nav-number">1.3.</span> <span class="nav-text">docker仓库使用</span></a><ol class="nav-child"><li class="nav-item nav-level-3"><a class="nav-link" href="#Docker-Hub"><span class="nav-number">1.3.1.</span> <span class="nav-text">Docker Hub</span></a></li><li class="nav-item nav-level-3"><a class="nav-link" href="#注册"><span class="nav-number">1.3.2.</span> <span class="nav-text">注册</span></a></li><li class="nav-item nav-level-3"><a class="nav-link" href="#拉取镜像"><span class="nav-number">1.3.3.</span> <span class="nav-text">拉取镜像</span></a></li></ol></li><li class="nav-item nav-level-2"><a class="nav-link" href="#docker-数据管理"><span class="nav-number">1.4.</span> <span class="nav-text">docker 数据管理</span></a><ol class="nav-child"><li class="nav-item nav-level-3"><a class="nav-link" href="#docker的文件系统"><span class="nav-number">1.4.1.</span> <span class="nav-text">docker的文件系统</span></a></li><li class="nav-item nav-level-3"><a class="nav-link" href="#volume文件挂载的探究"><span class="nav-number">1.4.2.</span> <span class="nav-text">volume文件挂载的探究</span></a></li></ol></li><li class="nav-item nav-level-2"><a class="nav-link" href="#Dockerfile使用"><span class="nav-number">1.5.</span> <span class="nav-text">Dockerfile使用</span></a><ol class="nav-child"><li class="nav-item nav-level-3"><a class="nav-link" href="#什么是-Dockerfile？"><span class="nav-number">1.5.1.</span> <span class="nav-text">什么是 Dockerfile？</span></a></li><li class="nav-item nav-level-3"><a class="nav-link" href="#dockerfile基本要素"><span class="nav-number">1.5.2.</span> <span class="nav-text">dockerfile基本要素</span></a></li><li class="nav-item nav-level-3"><a class="nav-link" href="#使用-Dockerfile-创建httpd镜像"><span class="nav-number">1.5.3.</span> <span class="nav-text">使用 Dockerfile 创建httpd镜像</span></a><ol class="nav-child"><li class="nav-item nav-level-4"><a class="nav-link" href="#1-创建镜像工作目录并进入"><span class="nav-number">1.5.3.1.</span> <span class="nav-text">1.创建镜像工作目录并进入</span></a></li><li class="nav-item nav-level-4"><a class="nav-link" href="#2-创建并编写dockerfile文件"><span class="nav-number">1.5.3.2.</span> <span class="nav-text">2.创建并编写dockerfile文件</span></a></li><li class="nav-item nav-level-4"><a class="nav-link" href="#3-创建脚本文件"><span class="nav-number">1.5.3.3.</span> <span class="nav-text">3.创建脚本文件</span></a></li><li class="nav-item nav-level-4"><a class="nav-link" href="#4-创建网站首页文件"><span class="nav-number">1.5.3.4.</span> <span class="nav-text">4.创建网站首页文件</span></a></li><li class="nav-item nav-level-4"><a class="nav-link" href="#5-查看当前目录文件列表"><span class="nav-number">1.5.3.5.</span> <span class="nav-text">5.查看当前目录文件列表</span></a></li><li class="nav-item nav-level-4"><a class="nav-link" href="#6-通过Dockerfile文件生成镜像"><span class="nav-number">1.5.3.6.</span> <span class="nav-text">6.通过Dockerfile文件生成镜像</span></a></li><li class="nav-item nav-level-4"><a class="nav-link" href="#7-镜像文件加载到容器中运行"><span class="nav-number">1.5.3.7.</span> <span class="nav-text">7.镜像文件加载到容器中运行</span></a></li><li class="nav-item nav-level-4"><a class="nav-link" href="#8-查看运行中的容器"><span class="nav-number">1.5.3.8.</span> <span class="nav-text">8.查看运行中的容器</span></a></li><li class="nav-item nav-level-4"><a class="nav-link" href="#9-运行浏览器测试httpd服务"><span class="nav-number">1.5.3.9.</span> <span class="nav-text">9.运行浏览器测试httpd服务</span></a></li></ol></li></ol></li><li class="nav-item nav-level-2"><a class="nav-link" href="#参考文章"><span class="nav-number">1.6.</span> <span class="nav-text">参考文章</span></a></li></ol></li></ol></div>
            

          </div>
        </section>
      <!--/noindex-->
      

      

    </div>
  </aside>


        
      </div>
    </main>

    <footer id="footer" class="footer">
      <div class="footer-inner">
        <div class="copyright">&copy; 2018 &mdash; <span itemprop="copyrightYear">2020</span>
  <span class="with-love">
    <i class="fa fa-user"></i>
  </span>
  <span class="author" itemprop="copyrightHolder">ctrl</span>

  
    <span class="post-meta-divider">|</span>
    <span class="post-meta-item-icon">
      <i class="fa fa-area-chart"></i>
    </span>
    
      <span class="post-meta-item-text">站点字数总计&#58;</span>
    
    <span title="站点字数总计">19.6k</span>

  <script async src="//busuanzi.ibruce.info/busuanzi/2.3/busuanzi.pure.mini.js"></script>
        <span class="post-meta-divider">|</span>
        <span class="post-meta-item-icon"><i class="fa fa-eye"></i></span>
        总访问量：<span id="busuanzi_value_site_pv"></span>次
        <span class="post-meta-divider">|</span>
        <span class="post-meta-item-icon"><i class="fa fa-user"></i></span>
        总访客：<span id="busuanzi_value_site_uv"></span>人
  
  

  
</div>




 <!--

<div class="powered-by">由 <a class="theme-link" target="_blank" href="https://hexo.io">Hexo</a> 强力驱动</div>



  <span class="post-meta-divider">|</span>



  <div class="theme-info">主题 &mdash; <a class="theme-link" target="_blank" href="https://github.com/iissnan/hexo-theme-next">NexT.Gemini</a> v</div>



-->

        
<div class="busuanzi-count">
  <script async src="https://busuanzi.ibruce.info/busuanzi/2.3/busuanzi.pure.mini.js"></script>

  

  
</div>








        
      </div>
    </footer>

    
      <div class="back-to-top">
        <i class="fa fa-arrow-up"></i>
        
      </div>
    

    

  </div>

  

<script type="text/javascript">
  if (Object.prototype.toString.call(window.Promise) !== '[object Function]') {
    window.Promise = null;
  }
</script>









  












  
  
    <script type="text/javascript" src="//cdn.jsdelivr.net/jquery/2.1.3/jquery.min.js"></script>
  

  
  
    <script type="text/javascript" src="//cdn.jsdelivr.net/fastclick/1.0.6/fastclick.min.js"></script>
  

  
  
    <script type="text/javascript" src="//cdn.jsdelivr.net/jquery.lazyload/1.9.3/jquery.lazyload.min.js"></script>
  

  
  
    <script type="text/javascript" src="//cdn.jsdelivr.net/velocity/1.2.3/velocity.min.js"></script>
  

  
  
    <script type="text/javascript" src="//cdn.jsdelivr.net/velocity/1.2.3/velocity.ui.min.js"></script>
  

  
  
    <script type="text/javascript" src="//cdn.jsdelivr.net/fancybox/2.1.5/jquery.fancybox.pack.js"></script>
  


  


  <script type="text/javascript" src="/js/src/utils.js?v="></script>

  <script type="text/javascript" src="/js/src/motion.js?v="></script>



  
  


  <script type="text/javascript" src="/js/src/affix.js?v="></script>

  <script type="text/javascript" src="/js/src/schemes/pisces.js?v="></script>



  
  <script type="text/javascript" src="/js/src/scrollspy.js?v="></script>
<script type="text/javascript" src="/js/src/post-details.js?v="></script>



  


  <script type="text/javascript" src="/js/src/bootstrap.js?v="></script>



  


  




	





  





  










  <script src="//cdn1.lncld.net/static/js/3.0.4/av-min.js"></script>
  <script src="//unpkg.com/valine/dist/Valine.min.js"></script>
  
  <script type="text/javascript">
    var GUEST = ['nick','mail','link'];
    var guest = 'nick,mail,link';
    guest = guest.split(',').filter(item=>{
      return GUEST.indexOf(item)>-1;
    });
    new Valine({
        el: '#comments' ,
        verify: false,
        notify: false,
        appId: 'x7eMnnknw8DLXiaQHKGDXYth-gzGzoHsz',
        appKey: 'Vj1vJImPLhxvGJIpsiDppAGm',
        placeholder: 'ヾﾉ≧∀≦)o来啊，快活啊!',
        avatar:'mm',
        guest_info:guest,
        pageSize:'10' || 10,
    });
  </script>



  





  

  
  <script src="https://cdn1.lncld.net/static/js/av-core-mini-0.6.4.js"></script>
  <script>AV.initialize("x7eMnnknw8DLXiaQHKGDXYth-gzGzoHsz", "Vj1vJImPLhxvGJIpsiDppAGm");</script>
  <script>
    function showTime(Counter) {
      var query = new AV.Query(Counter);
      var entries = [];
      var $visitors = $(".leancloud_visitors");

      $visitors.each(function () {
        entries.push( $(this).attr("id").trim() );
      });

      query.containedIn('url', entries);
      query.find()
        .done(function (results) {
          var COUNT_CONTAINER_REF = '.leancloud-visitors-count';

          if (results.length === 0) {
            $visitors.find(COUNT_CONTAINER_REF).text(0);
            return;
          }

          for (var i = 0; i < results.length; i++) {
            var item = results[i];
            var url = item.get('url');
            var time = item.get('time');
            var element = document.getElementById(url);

            $(element).find(COUNT_CONTAINER_REF).text(time);
          }
          for(var i = 0; i < entries.length; i++) {
            var url = entries[i];
            var element = document.getElementById(url);
            var countSpan = $(element).find(COUNT_CONTAINER_REF);
            if( countSpan.text() == '') {
              countSpan.text(0);
            }
          }
        })
        .fail(function (object, error) {
          console.log("Error: " + error.code + " " + error.message);
        });
    }

    function addCount(Counter) {
      var $visitors = $(".leancloud_visitors");
      var url = $visitors.attr('id').trim();
      var title = $visitors.attr('data-flag-title').trim();
      var query = new AV.Query(Counter);

      query.equalTo("url", url);
      query.find({
        success: function(results) {
          if (results.length > 0) {
            var counter = results[0];
            counter.fetchWhenSave(true);
            counter.increment("time");
            counter.save(null, {
              success: function(counter) {
                var $element = $(document.getElementById(url));
                $element.find('.leancloud-visitors-count').text(counter.get('time'));
              },
              error: function(counter, error) {
                console.log('Failed to save Visitor num, with error message: ' + error.message);
              }
            });
          } else {
            var newcounter = new Counter();
            /* Set ACL */
            var acl = new AV.ACL();
            acl.setPublicReadAccess(true);
            acl.setPublicWriteAccess(true);
            newcounter.setACL(acl);
            /* End Set ACL */
            newcounter.set("title", title);
            newcounter.set("url", url);
            newcounter.set("time", 1);
            newcounter.save(null, {
              success: function(newcounter) {
                var $element = $(document.getElementById(url));
                $element.find('.leancloud-visitors-count').text(newcounter.get('time'));
              },
              error: function(newcounter, error) {
                console.log('Failed to create');
              }
            });
          }
        },
        error: function(error) {
          console.log('Error:' + error.code + " " + error.message);
        }
      });
    }

    $(function() {
      var Counter = AV.Object.extend("Counter");
      if ($('.leancloud_visitors').length == 1) {
        addCount(Counter);
      } else if ($('.post-title-link').length > 1) {
        showTime(Counter);
      }
    });
  </script>



  

  
<script>
(function(){
    var bp = document.createElement('script');
    var curProtocol = window.location.protocol.split(':')[0];
    if (curProtocol === 'https') {
        bp.src = 'https://zz.bdstatic.com/linksubmit/push.js';        
    }
    else {
        bp.src = 'http://push.zhanzhang.baidu.com/push.js';
    }
    var s = document.getElementsByTagName("script")[0];
    s.parentNode.insertBefore(bp, s);
})();
</script>


  
  

  

  

  

<script src="/live2dw/lib/L2Dwidget.min.js?094cbace49a39548bed64abff5988b05"></script><script>L2Dwidget.init({"pluginRootPath":"live2dw/","pluginJsPath":"lib/","pluginModelPath":"assets/","model":{"jsonPath":"/live2dw/assets/wanko.model.json"},"display":{"position":"right","width":150,"height":300},"mobile":{"show":false},"log":false,"tagMode":false});</script></body>
</html>
